package com.songlanyun.modules.marketing.firstorder.controller.api;

import cn.hutool.core.util.ObjectUtil;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.account.controller.common.AbstractApiController;
import com.songlanyun.modules.marketing.firstorder.entity.FirstOrderActivity;
import com.songlanyun.modules.marketing.firstorder.service.FirstOrderActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 首单活动
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2020-11-23 16:29:49
 */
@RestController
@RequestMapping("api/marketing/firstOrder")
public class FirstOrderActivityApiController extends AbstractApiController {
    @Autowired
    private FirstOrderActivityService firstOrderActivityService;

    /**
     * 查询该商家下的首单优惠
     */
    @GetMapping("/getByShop/{shopId}")
//    @RequiresPermissions("oss:firstOrderActivity:list")
    public R getByShop(@PathVariable("shopId") Long shopId) {
        //商家查看自己的首单优惠
        FirstOrderActivity data = firstOrderActivityService.getApiByShopId(shopId,false);
        if(ObjectUtil.isNull(data))
        {
            data = new FirstOrderActivity();
            data.setShopId(shopId);
            data.setIsUse(false);
        }

        return R.ok().put("data", data);
    }


}
